#!/bin/bash
scriptWorkd=$(cd "$(dirname $0)";pwd)

### ========= 全局变量 ===========
otherSciprtPath="./bin-for-install"
### ==============================

### ========= 前置文件 ===========
if [[ -f ${HOME}/bin/basic_func.sh ]];then  ### 存在才载入
    source ${HOME}/bin/basic_func.sh
elif [[ -f ./bin/basic_func.sh ]];then
    source ./bin/basic_func.sh
fi
source ./bin-for-install/0.common_func.sh
### ==============================


#!/bin/bash
# echo -e "本脚本不建议使用sudo执行\n"


function main() {
set -e
    userSelect "开始安装(To run scripts)" y

    git config --global http.sslVerity false
    echo -e "${hintStrProcessing}${yellow}更换apt源(Changing apt sources)${normal}"
    bash ${otherSciprtPath}/02.change-apt-sources.sh

    ### 会返回错误代码吗？
    if [[ $? -ne 0 ]]; then
        echo -e "${red}Error occured${normal}"
    	exit
    fi
  
    ### common_func
    echo -e "${hintStrProcessing}${yellow}WSL特殊预处理(Special WSL configuration)${normal}"
    pathCleaner
  
    ### 使用外部脚本安装apt相关软件。
    echo -e "${hintStrProcessing}${yellow}安装软件(Installing by apt)${normal}"
    bash ${otherSciprtPath}/01.install-apt-softwares.sh

    ### common_func
    echo -e "${hintStrProcessing}${yellow}安装插件管理器(Installing addon managers)${normal}"
    install-addon-managers
    
    ### language-set必须在apt运行之后再运行
    
    alias cp='rsycn -ah --info=progress2'
  
    echo -e "${hintStrProcessing}${yellow}安装nvim(Installing neovim)${normal}"
    bash ${otherSciprtPath}/07.install-nvim.sh
  
    echo -e "${hintStrProcessing}${yellow}设置语言(Setting locale)${normal}"
    source ${otherSciprtPath}/03.set-locale.sh

    echo -e "${hintStrProcessing}${yellow}安装新字体(Installing new fonts)${normal}"
    source ${otherSciprtPath}/08.install-fonts.sh

    echo -e "${hintStrProcessing}${yellow}配置node(installing node.20.12.2)${normal}"
    bash ${otherSciprtPath}/09.install-node20.sh


    echo -e "${hintStrProcessing}${yellow}复制(Copying resources files)${normal}"
    bash ${otherSciprtPath}/04.copy.sh

    rm -rf ${scriptWorkd}/temp
set -e
}

main $@

echo -e "${hintStrSucceed}\e[1;5m安装完毕，请重启Shell${normal}"
echo -e "          \e[1;5mScript executed successfully, Please relaunch shell${normal}."
